home *** CD-ROM | disk | FTP | other *** search
/ MacWarehouse Macintosh Games / MacWarehouse Macintosh Games.iso / AMBER demo / ROXY / ROXY.dxr / 00005_REPORT, other generic domain handlers.ls < prev    next >
Encoding:
Text File  |  1996-10-18  |  16.8 KB  |  506 lines

  1. on report outString
  2.   global testData
  3.   exit
  4.   if objectp(testData) then
  5.     testData(mWriteString, outString & RETURN)
  6.   else
  7.     put outString
  8.   end if
  9. end
  10.  
  11. on REPORT2 outString
  12.   global testData
  13.   exit
  14.   if objectp(testData) then
  15.     testData(mWriteString, outString & RETURN)
  16.   else
  17.     put outString
  18.   end if
  19. end
  20.  
  21. on preloadLocations
  22.   global oPuppeteer
  23.   set the preLoadEventAbort to 0
  24.   set thisLoc to getState(oStoryteller, #currentLocation)
  25.   set loadList to getProp(getLocationPointer(oPuppeteer, thisLoc), #preLoad)
  26.   set loadSize to 0
  27.   repeat with myNumber in loadList
  28.     if the loaded of cast myNumber = 0 then
  29.       preLoadCast(myNumber)
  30.       set loadSize to loadSize + the size of cast myNumber
  31.     end if
  32.   end repeat
  33. end
  34.  
  35. on wait howLong, whichSound
  36.   global oStoryteller
  37.   if howLong = #videoStop then
  38.     repeat while the movieRate of sprite 44 > 0
  39.       updateStage()
  40.     end repeat
  41.     exit
  42.   end if
  43.   if howLong = #soundStop then
  44.     set theChannel to #none
  45.     set soundChannels to getProp(the lsStateData of oStoryteller, #soundChannels)
  46.     repeat with i = 1 to count(soundChannels)
  47.       set channelData to getAt(soundChannels, i)
  48.       if getProp(channelData, #sndName) = whichSound then
  49.         set theChannel to getPropAt(soundChannels, i)
  50.       end if
  51.     end repeat
  52.     if theChannel <> #none then
  53.       repeat while soundBusy(theChannel)
  54.         updateStage()
  55.       end repeat
  56.     end if
  57.     exit
  58.   end if
  59.   if integerp(howLong) then
  60.     startTimer()
  61.     repeat while the timer < howLong
  62.       updateStage()
  63.     end repeat
  64.   end if
  65. end
  66.  
  67. on initMultiFrames
  68.   global oStoryteller, oPuppeteer
  69.   exit
  70.   set frameStack to getProp(the lsMultiFrames of oPuppeteer, #levelDigits)
  71.   set firstFrame to getAt(frameStack, getState(oStoryteller, #BarLevel) + 2)
  72.   set the palette of cast "BAR-FM.frame" to the palette of cast firstFrame
  73.   puppetPalette(the palette of cast firstFrame)
  74.   updateStage()
  75.   set the picture of cast getAt(frameStack, 1) to the picture of cast firstFrame
  76.   set frameStack to getProp(the lsMultiFrames of oPuppeteer, #gainDigits)
  77.   set firstFrame to getAt(frameStack, getState(oStoryteller, #BarGain) + 2)
  78.   set the palette of cast "BAR-FM.frame" to the palette of cast firstFrame
  79.   put "'gain' palette is " & the palette of cast "BAR-FM.frame"
  80.   puppetPalette(the palette of cast firstFrame)
  81.   updateStage()
  82.   set the picture of cast getAt(frameStack, 1) to the picture of cast firstFrame
  83.   set frameStack to getProp(the lsMultiFrames of oPuppeteer, #FMdigits)
  84.   set firstFrame to getAt(frameStack, getState(oStoryteller, #BarFM) + 2)
  85.   puppetPalette(the palette of cast firstFrame)
  86.   updateStage()
  87.   set the picture of cast getAt(frameStack, 1) to the picture of cast firstFrame
  88. end
  89.  
  90. on initInventory
  91.   global oStoryteller, oPuppeteer, gOriginPoint
  92.   set the lsInventory of oPuppeteer to [#none, #none, #none, #none, #none, #none, #none]
  93.   if getState(oStoryteller, #itemInUse) <> #Headgear then
  94.     setState(oStoryteller, #itemInUse, #none)
  95.   end if
  96.   if getState(oStoryteller, #inventoryStatus) = #cool then
  97.     freezeInventory()
  98.   else
  99.     unFreezeInventory()
  100.   end if
  101.   repeat with i = 1 to count(the lsInventoryData of oPuppeteer)
  102.     set candidate to getPropAt(the lsInventoryData of oPuppeteer, i)
  103.     set itemState to getState(oStoryteller, value("#playerHas" & candidate))
  104.     if (itemState <> 0) and (itemState <> #usedUp) then
  105.       if (candidate = #Headgear) and (getState(oStoryteller, #playerHasHeadgear) = #inUse) then
  106.         puppetSprite(39, 1)
  107.         if getState(oStoryteller, #houseLightsAreOn) = 1 then
  108.           set hgCast to getProp(the lsForegroundData of oPuppeteer, #Headgear)
  109.         else
  110.           set hgCast to getProp(the lsForegroundData of oPuppeteer, #HeadgearOff)
  111.         end if
  112.         set the castNum of sprite 39 to hgCast
  113.         set the loc of sprite 39 to point(320, 129) + gOriginPoint
  114.         set the ink of sprite 39 to 8
  115.         setState(oStoryteller, value("#playerHas" & candidate), itemState)
  116.       else
  117.         addInventory(candidate, #quietly)
  118.         setState(oStoryteller, value("#playerHas" & candidate), #carrying)
  119.       end if
  120.       next repeat
  121.     end if
  122.   end repeat
  123.   cursorOff()
  124.   fadeOutTransit()
  125.   moveToLocation(oPuppeteer)
  126.   setTransition(oPuppeteer, #fadeIn)
  127.   updateDisplay(oPuppeteer)
  128.   if getState(oStoryteller, #currentLocation) = #DarkUp_40sReentry then
  129.     fadeOutTransit()
  130.     trimState(#ghostsRemaining, #Margaret)
  131.     ghostCalls(#none)
  132.     trimState(#hauntsRemaining, #ghostBrushingHair)
  133.     trimState(#hauntsRemaining, #stairsGhost)
  134.     setLoop(#houseHum, 96)
  135.     setState(oStoryteller, #showMontage, 1)
  136.     setTransition(oPuppeteer, #slowMontage)
  137.     updateDisplay(oPuppeteer)
  138.     setState(oStoryteller, #PeekDisplay, #psionicFragment)
  139.     peekAlert()
  140.   end if
  141.   if getState(oStoryteller, #currentLocation) = #Ggaz_Reentry then
  142.     fadeOutTransit()
  143.     trimState(#ghostsRemaining, #Brice)
  144.     ghostCalls(#none)
  145.     trimState(#hauntsRemaining, #knifeShadow)
  146.     trimState(#hauntsRemaining, #hungMan)
  147.     trimState(#hauntsRemaining, #TVghost)
  148.     trimState(#hauntsRemaining, #gazebo1)
  149.     trimState(#hauntsRemaining, #gazebo2)
  150.     trimState(#hauntsRemaining, #gazebo3)
  151.     setState(oStoryteller, #showMontage, 1)
  152.     setTransition(oPuppeteer, #slowMontage)
  153.     updateDisplay(oPuppeteer)
  154.     setState(oStoryteller, #PeekDisplay, #psionicFragment)
  155.     peekAlert()
  156.   end if
  157.   if getState(oStoryteller, #currentLocation) = #Gbhs_Reentry1 then
  158.     fadeOutTransit()
  159.     trimState(#ghostsRemaining, #Edwin)
  160.     ghostCalls(#none)
  161.     trimState(#hauntsRemaining, #lakeGhost)
  162.     trimState(#hauntsRemaining, #lakeGhost2)
  163.     setState(oStoryteller, #showMontage, 1)
  164.     setTransition(oPuppeteer, #slowMontage)
  165.     updateDisplay(oPuppeteer)
  166.     setState(oStoryteller, #PeekDisplay, #psionicFragment)
  167.     peekAlert()
  168.   end if
  169.   if getState(oStoryteller, #currentLocation) = #Gbhs_playIntro then
  170.     pushVideo()
  171.     repeat while (the movieRate of sprite 44 <> 0) and not (the mouseDown)
  172.       updateStage()
  173.     end repeat
  174.     killVideo()
  175.     goTo(#Gbhs_GameEntry, #fadeIn)
  176.   end if
  177. end
  178.  
  179. on addInventory whichItem, optionalSwitch
  180.   global oPuppeteer, gOriginPoint
  181.   set inventoryList to the lsInventory of oPuppeteer
  182.   if the paramCount < 1 then
  183.     put "Hey, you can't call addInventory without an argument.."
  184.     exit
  185.   end if
  186.   if voidp(getaProp(the lsInventoryData of oPuppeteer, whichItem)) then
  187.     put "Hey, there's no such thing in this inventory..."
  188.     exit
  189.   end if
  190.   if getPos(inventoryList, whichItem) then
  191.     put "Hey, " & whichItem & " is already in inventory..."
  192.     exit
  193.   end if
  194.   if whichItem = #Headgear then
  195.     set the loc of sprite 39 to point(-1000, -1000) + gOriginPoint
  196.     puppetSprite(39, 0)
  197.   end if
  198.   setState(oStoryteller, value("#playerHas" & whichItem), #carrying)
  199.   if getAt(inventoryList, 4) = #none then
  200.     setAt(inventoryList, 4, whichItem)
  201.   else
  202.     set leftSlotsOpen to 0
  203.     set rightSlotsOpen to 0
  204.     repeat with i = 1 to 3
  205.       if getAt(inventoryList, i) <> #none then
  206.         exit repeat
  207.       end if
  208.       set leftSlotsOpen to leftSlotsOpen + 1
  209.     end repeat
  210.     repeat with i = 7 down to 5
  211.       if getAt(inventoryList, i) <> #none then
  212.         exit repeat
  213.       end if
  214.       set rightSlotsOpen to rightSlotsOpen + 1
  215.     end repeat
  216.     if whichItem = #PeekUnit then
  217.       if (getAt(inventoryList, 4) = #ScanDevice) or (getAt(inventoryList, 4) = #Headgear) then
  218.         if getAt(inventoryList, 4) = #ScanDevice then
  219.           if leftSlotsOpen then
  220.             deleteAt(inventoryList, 1)
  221.             addAt(inventoryList, 4, whichItem)
  222.           else
  223.             deleteAt(inventoryList, 7)
  224.             addAt(inventoryList, 4, whichItem)
  225.           end if
  226.         else
  227.           if rightSlotsOpen then
  228.             deleteAt(inventoryList, 7)
  229.             addAt(inventoryList, 4, whichItem)
  230.           else
  231.             deleteAt(inventoryList, 1)
  232.             addAt(inventoryList, 4, whichItem)
  233.           end if
  234.         end if
  235.       else
  236.         set whichSide to #right
  237.         if leftSlotsOpen > rightSlotsOpen then
  238.           set whichSide to #left
  239.         end if
  240.         if whichSide = #left then
  241.           deleteAt(inventoryList, 1)
  242.         else
  243.           deleteAt(inventoryList, 7)
  244.         end if
  245.         addAt(inventoryList, 4, whichItem)
  246.       end if
  247.     else
  248.       if whichItem = #ScanDevice then
  249.         if leftSlotsOpen < 1 then
  250.           deleteAt(inventoryList, 7)
  251.           addAt(inventoryList, 8 - rightSlotsOpen, whichItem)
  252.         else
  253.           deleteAt(inventoryList, 1)
  254.           addAt(inventoryList, 0 + leftSlotsOpen, whichItem)
  255.         end if
  256.       else
  257.         if whichItem = #Headgear then
  258.           if rightSlotsOpen < 1 then
  259.             deleteAt(inventoryList, 1)
  260.             addAt(inventoryList, 0 + leftSlotsOpen, whichItem)
  261.           else
  262.             deleteAt(inventoryList, 7)
  263.             addAt(inventoryList, 8 - rightSlotsOpen, whichItem)
  264.           end if
  265.         else
  266.           set whichSide to #right
  267.           if leftSlotsOpen > rightSlotsOpen then
  268.             set whichSide to #left
  269.           end if
  270.           if whichSide = #left then
  271.             deleteAt(inventoryList, 1)
  272.             addAt(inventoryList, 0 + leftSlotsOpen, whichItem)
  273.           else
  274.             deleteAt(inventoryList, 7)
  275.             addAt(inventoryList, 8 - rightSlotsOpen, whichItem)
  276.           end if
  277.         end if
  278.       end if
  279.     end if
  280.   end if
  281.   updateInventory()
  282.   if optionalSwitch <> #quietly then
  283.     setTransition(oPuppeteer, #fadeIn)
  284.     updateDisplay(oPuppeteer)
  285.     glimpseInventory(whichItem)
  286.   end if
  287. end
  288.  
  289. on deleteInventory whichItem
  290.   global oPuppeteer, oStoryteller
  291.   set inventoryList to the lsInventory of oPuppeteer
  292.   if the paramCount < 1 then
  293.     put "Hey, you can't call deleteInventory without an argument.."
  294.     exit
  295.   end if
  296.   set itsPosition to getPos(inventoryList, whichItem)
  297.   if not itsPosition then
  298.     put "The item " & whichItem & " isn't IN inventory; can't delete.."
  299.     exit
  300.   end if
  301.   if (whichItem = #ScanDevice) or (whichItem = #Headgear) then
  302.     if whichItem = #ScanDevice then
  303.       setState(oStoryteller, value("#playerHas" & whichItem), 0)
  304.     end if
  305.     if whichItem = #Headgear then
  306.       setState(oStoryteller, value("#playerHas" & whichItem), #inUse)
  307.     end if
  308.   else
  309.     setState(oStoryteller, value("#playerHas" & whichItem), #usedUp)
  310.   end if
  311.   if getState(oStoryteller, #itemInUse) = whichItem then
  312.     setState(oStoryteller, #itemInUse, #none)
  313.   end if
  314.   if itsPosition < 4 then
  315.     deleteAt(inventoryList, itsPosition)
  316.     addAt(inventoryList, 1, #none)
  317.   else
  318.     if itsPosition > 4 then
  319.       deleteAt(inventoryList, itsPosition)
  320.       addAt(inventoryList, 7, #none)
  321.     else
  322.       set leftSlotsOpen to 0
  323.       set rightSlotsOpen to 0
  324.       repeat with i = 1 to 3
  325.         if getAt(inventoryList, i) <> #none then
  326.           exit repeat
  327.         end if
  328.         set leftSlotsOpen to leftSlotsOpen + 1
  329.       end repeat
  330.       repeat with i = 7 down to 5
  331.         if getAt(inventoryList, i) <> #none then
  332.           exit repeat
  333.         end if
  334.         set rightSlotsOpen to rightSlotsOpen + 1
  335.       end repeat
  336.       set whichSide to #right
  337.       if leftSlotsOpen > rightSlotsOpen then
  338.         set whichSide to #left
  339.       end if
  340.       if whichSide = #left then
  341.         addAt(inventoryList, 7, #none)
  342.         deleteAt(inventoryList, 4)
  343.       else
  344.         deleteAt(inventoryList, 4)
  345.         addAt(inventoryList, 1, #none)
  346.       end if
  347.     end if
  348.   end if
  349.   updateInventory()
  350.   setTransition(oPuppeteer, #fadeIn)
  351.   updateDisplay(oPuppeteer)
  352. end
  353.  
  354. on useInventory whichItem
  355.   global oPuppeteer, oStoryteller, thisCursor, lastCursor, gOriginPoint
  356.   set negateList to [#playerIsReadingNoteInStudy, #playerIsExaminingHeadgear, #playerIsExaminingOscillator, #playerIsExaminingWeedkiller, #playerIsExaminingVideotape, #playerIsReadingDreamDiary, #playerIsExaminingDreamDiary, #playerIsReadingBarManual, #playerIsExaminingBarManual, #playerIsExaminingPhone, #playerIsReadingRealms, #playerIsExaminingRealms, #playerIsExaminingPyramid, #playerIsExaminingHypnoFlier]
  357.   if whichItem = #PeekUnit then
  358.     if getState(oStoryteller, #itemInUse) = #PeekUnit then
  359.       exit
  360.     end if
  361.   end if
  362.   set mustFade to 0
  363.   repeat with i in negateList
  364.     if getState(oStoryteller, i) = 1 then
  365.       set mustFade to 1
  366.       setState(oStoryteller, i, 0)
  367.     end if
  368.   end repeat
  369.   if mustFade then
  370.     setTransition(oPuppeteer, #fadeIn)
  371.     updateDisplay(oPuppeteer)
  372.   end if
  373.   if getState(oStoryteller, #itemInUse) = #PeekUnit then
  374.     stowInventory(#PeekUnit)
  375.   end if
  376.   setState(oStoryteller, #itemInUse, whichItem)
  377.   repeat with i in the lsInventory of oPuppeteer
  378.     if i <> #none then
  379.       if i = whichItem then
  380.         setState(oStoryteller, value("#playerHas" & i), #inUse)
  381.         next repeat
  382.       end if
  383.       if not ((i = #Headgear) and (getState(oStoryteller, #endGame) = 0)) then
  384.         setState(oStoryteller, value("#playerHas" & i), #carrying)
  385.       end if
  386.     end if
  387.   end repeat
  388.   if whichItem = #Headgear then
  389.     if getState(oStoryteller, #endGame) = 1 then
  390.       setState(oStoryteller, #playerHasHeadgear, #endGame)
  391.       setState(oStoryteller, #itemInUse, #Headgear)
  392.     else
  393.       setState(oStoryteller, #itemInUse, #none)
  394.       deleteInventory(#Headgear)
  395.       setState(oStoryteller, #playerHasHeadgear, #inUse)
  396.       puppetSprite(39, 1)
  397.       set hgCast to getProp(the lsForegroundData of oPuppeteer, #HeadgearOff)
  398.       set the castNum of sprite 39 to hgCast
  399.       set the loc of sprite 39 to point(320, 129) + gOriginPoint
  400.       set the ink of sprite 39 to 8
  401.       setTransition(oPuppeteer, #fadeIn)
  402.     end if
  403.   end if
  404.   updateInventory()
  405.   if whichItem = #PeekUnit then
  406.     usePeekUnit()
  407.   end if
  408.   updateDisplay(oPuppeteer)
  409.   if (whichItem = #Headgear) and getState(oStoryteller, #houseLightsAreOn) and (getState(oStoryteller, #endGame) = 0) then
  410.     wait(10)
  411.     set the castNum of sprite 39 to getProp(the lsForegroundData of oPuppeteer, #Headgear)
  412.     updateStage()
  413.     wait(5)
  414.     if getState(oStoryteller, #houseLightsAreOn) then
  415.       setState(oStoryteller, #AMBERVISION, #on)
  416.     end if
  417.     setLoop(#amberHum)
  418.   end if
  419.   updateDisplay(oPuppeteer)
  420. end
  421.  
  422. on stowInventory whichItem
  423.   global oPuppeteer, oStoryteller, gOriginPoint, gCPU
  424.   setState(oStoryteller, #itemInUse, #none)
  425.   setState(oStoryteller, value("#playerHas" & whichItem), #carrying)
  426.   if whichItem = #PeekUnit then
  427.     killVideo()
  428.     set peekBody to 38
  429.     set peekAntenna to 46
  430.     set peekText to 40
  431.     set pkScanIcon to 41
  432.     set pkBarIcon to 42
  433.     set pkAmberIcon to 43
  434.     set the loc of sprite peekBody to point(-500, -500)
  435.     set the loc of sprite peekAntenna to point(-500, -500)
  436.     set the loc of sprite peekText to point(-500, -500)
  437.     set the loc of sprite pkScanIcon to point(-500, -500)
  438.     set the loc of sprite pkBarIcon to point(-500, -500)
  439.     set the loc of sprite pkAmberIcon to point(-500, -500)
  440.     puppetSprite(peekBody, 0)
  441.     puppetSprite(peekAntenna, 0)
  442.     puppetSprite(peekText, 0)
  443.     puppetSprite(pkScanIcon, 0)
  444.     puppetSprite(pkBarIcon, 0)
  445.     puppetSprite(pkAmberIcon, 0)
  446.     updateInventory()
  447.     do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #fadeIn))
  448.     updateDisplay(oPuppeteer)
  449.     if gCPU = #PC then
  450.       restoreSounds(#fadeIn)
  451.     end if
  452.     testForPsionicWaves()
  453.     if getPos(the lsInventory of oPuppeteer, #PeekUnit) then
  454.       glimpseInventory(whichItem)
  455.     else
  456.       addInventory(#PeekUnit)
  457.     end if
  458.     if getState(oStoryteller, #AMBERVISION) = #startingUp then
  459.       goTo(#StudyAmberMid, #backOff)
  460.       pushVideo()
  461.       wait(#videoStop)
  462.       set the castNum of sprite 39 to getProp(the lsForegroundData of oPuppeteer, #Headgear)
  463.       setState(oStoryteller, #AMBERVISION, #on)
  464.       setLoop(#amberHum)
  465.     end if
  466.   else
  467.     if whichItem = #Headgear then
  468.       set the loc of sprite 39 to point(-1000, -1000) + gOriginPoint
  469.       puppetSprite(39, 0)
  470.     end if
  471.     if whichItem = #WeedKiller then
  472.       soundEffect(#WeedKiller)
  473.     end if
  474.     if getPos(the lsInventory of oPuppeteer, whichItem) then
  475.       updateInventory()
  476.       setTransition(oPuppeteer, #fadeIn)
  477.       updateDisplay(oPuppeteer)
  478.       glimpseInventory(whichItem)
  479.     else
  480.       addInventory(whichItem)
  481.     end if
  482.   end if
  483. end
  484.  
  485. on glimpseInventory whichItem
  486.   global oPuppeteer, gOriginPoint
  487.   set foundationSprite to 3
  488.   set itemV to 410
  489.   set myPosition to getPos(the lsInventory of oPuppeteer, whichItem)
  490.   set itemH to 40 + (70 * myPosition)
  491.   set whichSprite to myPosition + foundationSprite
  492.   if whichSprite > foundationSprite then
  493.     cursorOff()
  494.     puppetSprite(whichSprite, 1)
  495.     set the castNum of sprite whichSprite to getAt(getProp(the lsInventoryData of oPuppeteer, whichItem), 1)
  496.     set the loc of sprite whichSprite to point(itemH, itemV) + gOriginPoint
  497.     updateStage()
  498.     if the inventoryStatus of oPuppeteer = #cool then
  499.       wait(25)
  500.       set the castNum of sprite whichSprite to getAt(getProp(the lsInventoryData of oPuppeteer, whichItem), 2)
  501.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #fadeIn))
  502.       updateStage()
  503.     end if
  504.   end if
  505. end
  506.